package main

import "fmt"

// 使用继承修改前的例子见笔记

type Student struct {
	Name  string
	Age   int
	Score int
}

func (stu *Student) ShowInfo() {
	fmt.Printf("学生名：%v，年龄：%v，成绩：%v\n", stu.Name, stu.Age, stu.Score)
}

func (stu *Student) SetScore(score int) {
	stu.Score = score
}

func (stu *Student) Testing() {
	fmt.Println("正在考试中........")
}

type Pupil struct {
	Student
}

func (p *Pupil) Testing() {
	fmt.Println("小学生正在考试中........")
}

type Graduate struct {
	Student
}

func (g *Graduate) Testing() {
	fmt.Println("大学生正在考试中........")
}

func main() {
	var p = &Pupil{
		Student{
			Name: "Jack",
			Age:  10,
		},
	}
	p.Student.Name = "Jack"
	p.Student.Age = 10
	p.Testing()
	p.Student.Testing()
	p.Student.SetScore(90)
	p.Student.ShowInfo()
	var g = &Graduate{
		Student{
			Name: "Tom",
			Age:  20,
		},
	}
	g.Testing()
	g.SetScore(85)
	g.ShowInfo()

	var g1 = &Graduate{}
	g1.Student.Name = "Tom"
	g1.Student.Age = 20
	var g3 = &Graduate{}
	g3.Name = "Tom"
	g3.Age = 20
}
